package com.ruoyi.behindDoctor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.behindDoctor.domain.yDocSysUser;
import com.ruoyi.behindDoctor.service.IyDocSysUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 所有医生Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/behindDoctor/yyybehinddoctor")
public class yDocSysUserController extends BaseController
{
    @Autowired
    private IyDocSysUserService yDocSysUserService;

    /**
     * 查询所有医生列表
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:list')")
    @GetMapping("/list")
    public TableDataInfo list(yDocSysUser yDocSysUser)
    {
        startPage();
        List<yDocSysUser> list = yDocSysUserService.selectyDocSysUserList(yDocSysUser);
        return getDataTable(list);
    }

    /**
     * 导出所有医生列表
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:export')")
    @Log(title = "所有医生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, yDocSysUser yDocSysUser)
    {
        List<yDocSysUser> list = yDocSysUserService.selectyDocSysUserList(yDocSysUser);
        ExcelUtil<yDocSysUser> util = new ExcelUtil<yDocSysUser>(yDocSysUser.class);
        util.exportExcel(response, list, "所有医生数据");
    }

    /**
     * 获取所有医生详细信息
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(yDocSysUserService.selectyDocSysUserByUserId(userId));
    }

    /**
     * 新增所有医生
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:add')")
    @Log(title = "所有医生", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody yDocSysUser yDocSysUser)
    {
        return toAjax(yDocSysUserService.insertyDocSysUser(yDocSysUser));
    }

    /**
     * 修改所有医生
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:edit')")
    @Log(title = "所有医生", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody yDocSysUser yDocSysUser)
    {
        return toAjax(yDocSysUserService.updateyDocSysUser(yDocSysUser));
    }

    /**
     * 删除所有医生
     */
    @PreAuthorize("@ss.hasPermi('behindDoctor:yyybehinddoctor:remove')")
    @Log(title = "所有医生", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(yDocSysUserService.deleteyDocSysUserByUserIds(userIds));
    }
}
